package com.joysuch.wwyt.bp.repository;

import com.joysuch.wwyt.bp.entity.investigate.BpSafeTable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author ZhangDong
 * @Date 2020/12/2 13:31
 */
public interface BpSafeTableDao extends JpaRepository<BpSafeTable, Long>, JpaSpecificationExecutor<BpSafeTable> {

    @Query(value = "select 1 from wwyt_bp_safe_table where table_name=:tableName and delete_flag='0' limit 1", nativeQuery = true)
    Integer countByTableName(String tableName);

    @Query(value = "update wwyt_bp_safe_table set delete_flag='1' where id=:id", nativeQuery = true)
    @Modifying
    void deleteById(Long id);

    List<BpSafeTable> findByTypeIdIn(List<Long> typeIdList);

}
